package cn.lijiajia3515.cairo.auth.modules.account;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public interface AccountInterface {

	/**
	 * find
	 *
	 * @param ids ids
	 * @return find map
	 */
	default Map<String, Account> findMap(Collection<String> ids) {
		return find(FindAccountParam.builder().uids(ids).build()).stream()
			.collect(Collectors.toMap(Account::getId, x -> x));
	}

	/**
	 * find
	 *
	 * @param param param
	 * @return user
	 */
	@PostMapping("/find")
	List<Account> find(@RequestBody FindAccountParam param);

	/**
	 * find
	 *
	 * @param id id
	 * @return user
	 */
	@GetMapping(path = "/find/{id}")
	Account findById(@PathVariable(name = "id") String id);


}
